package com.niit.controller;

import com.niit.model.*;
import com.niit.service.AdminService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author： 王治伟
 * @date:  2021年6月24日22:32:42
 * @description:
 *      调用service层的方法
 * @modified:
 * @Version: 1.0
 */
@RestController
@RequestMapping("/admin")
public class AdminConsumerRestController {

    @Resource
    private AdminService adminService;

    @GetMapping("/admin")
    public List<Admin> Adminlist() {
        return adminService.adminlist();
    }

    @GetMapping("/student")
    public List<Student> Studentlist() {
        return adminService.studentlist();
    }

    @GetMapping("/teacher")
    public List<Teacher> Teacherlist( ) {
        return adminService.teacherlist();
    }

    @GetMapping("/class")
    public List<Classes> Classlist( ) {
        return adminService.classlist();
    }

    @GetMapping("/question")
    public List<Question> Questionlist( ) {
        return adminService.questionslist();
    }

    @GetMapping("/exampaper")
    public List<ExamPaper> examPaperslist( ) {
        return adminService.exampaperslist();
    }

    @GetMapping("/admin/{id}")
    public Admin getadminById(@PathVariable("id") Long id) {
        return adminService.getadminById(id);
    }

    @GetMapping("/student/{id}")
    public Student getstudentById(@PathVariable("id") Long id) {
        return adminService.getstudentById(id);
    }

    @GetMapping("/teacher/{id}")
    public Teacher getteacherById(@PathVariable("id") Long id){ return adminService.getteacherById(id); }

    @GetMapping("/class/{id}")
    public Classes getclassById(@PathVariable("id") Long id){ return adminService.getclassById(id); }

    @GetMapping("/question/{id}")
    public Question getquestionById(@PathVariable("id") Long id){ return adminService.getquestionById(id); }

    @GetMapping("/exampaper/{id}")
    public ExamPaper getExamPaperById(@PathVariable("id") Long id){ return adminService.getExamPaperById(id); }

    @PostMapping("/admin")
    public String add(@RequestBody Admin admin){
        return adminService.add(admin) ;
    }

    @PostMapping("/student")
    public String add(@RequestBody Student student){
        return adminService.add(student);
    }

    @PostMapping("/teacher")
    public String add(@RequestBody Teacher teacher){
        return adminService.add(teacher);
    }

    @PostMapping("/class")
    public String add(@RequestBody Classes classes){
        return adminService.add(classes);
    }

    @PostMapping("/question")
    public String add(@RequestBody Question question){
        return adminService.add(question) ;
    }

    @PostMapping("/exampaper")
    public String add(@RequestBody ExamPaper examPaper){ return adminService.add(examPaper) ; }

    @PutMapping("/admin")
    public String updateadmin(@RequestBody Long id){ return adminService.updateadmin(id); }

    @PutMapping("/teacher")
    public String updateteacher(@RequestBody Long id){ return adminService.updateteacher(id) ; }

    @PutMapping("/student")
    public String updatestudent(@RequestBody Long id){ return adminService.updatestudent(id) ; }

    @PutMapping("/class")
    public String updateclass(@RequestBody Long id){
        return adminService.updateclass(id) ;
    }

    @PutMapping("/question")
    public String updatequestion(@RequestBody  Long id){ return adminService.updatequestion(id) ; }

    @PutMapping("/exampaper")
    public String updateexampaer(@RequestBody  Long id){ return adminService.updateexampaper(id);}

    @PutMapping("/status")
    String updatestatus(@RequestBody  Long id){ return adminService.updatestatus(id);}


    @DeleteMapping("/admin/{id}")
    public String deleteAdminById(@PathVariable("id") Long id){ return  adminService.deleteAdminById(id); }

    @DeleteMapping("/student/{id}")
    public String deleteStudentById(@PathVariable("id") Long id){ return  adminService.deleteStudentById(id) ; }

    @DeleteMapping("/teacher/{id}")
    public String deleteTeacherById(@PathVariable("id") Long id){ return  adminService.deleteTeacherById(id); }

    @DeleteMapping("/class/{id}")
    public String deleteClassById(@PathVariable("id") Long id){ return  adminService.deleteClassById(id); }

    @DeleteMapping("/question/{id}")
    public String deleteQuestionById(@PathVariable("id") Long id){ return  adminService.deleteQuestionById(id) ; }

    @DeleteMapping("/exampaper/{id}")
    public String deleteExamPaperById(@PathVariable("id") Long id){ return  adminService.deleteExamPaperById(id) ; }
}